package org.noip.milhous.clause;

import org.noip.milhous.SQLInterface;

public class OrderBy implements SQLInterface
{

	public static final String orderBy = " ORDER BY ";

	public static final String descend = " DESC ";

	public static final String ascend = " ASC ";

	public static final String LIMIT = " LIMIT ";

	public String Limit = null;

	public boolean descending = false;

	public Object data;

	public OrderBy(Object data, boolean descending)
		{
			super();
			this.data = data;
			this.descending = descending;
		}

	public OrderBy(Object data, boolean descending, Integer Limit)
		{
			super();
			this.data = data;
			this.descending = descending;
			this.Limit = Limit.toString();
		}

	public String toInternalSQL()
		{
			return data.toString() + (descending ? descend : ascend) + (Limit != null ? LIMIT + Limit : "");
		}

	public String toSQL()
		{
			return orderBy + toInternalSQL();
		}

}
